#include<bits/stdc++.h>
#define int long long

using namespace std;

// a ^ b = c --> a ^ c = b --> b ^ c = a;

signed main() {
	int t;
	cin >> t;
	while(t -- ) {
		int n;
		cin >> n;
		for(int j = 1; ; j ++ ) {
			if((n ^ j) >= 1 && (n ^ j) <= 1000000000) {
				cout << j << " " << (n ^ j ) << endl;
				break;
			}
		}
	}
	return 0;
}

